package com._520it.crm.web.controller;

import java.util.List;

import com.sun.javafx.sg.prism.NGShape;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com._520it.crm.domain.ClientEle;
import com._520it.crm.service.IClientEleService;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ClientEleController {
	@Autowired
	private IClientEleService service;
	@RequestMapping("/clientEle/index")
	public String index(){
		return "clientEle/index";
	}

	@RequestMapping("/clientEle/list/view")
	public ModelAndView selectAll(ModelAndView modelAndView,
								  @RequestParam(defaultValue = "1") int current,
								  @RequestParam(defaultValue = "10") int size,
								  String name,
								  String nature,
								  String antiLaunGrade,
								  String papersType,
								  String papersNum,
								  String address,
								  String aReplenish,
								  String tel

	){
		modelAndView.setViewName("clientEle/list");


		List<ClientEle> accountList = service.selectPage(current,size,name,nature,antiLaunGrade,
				papersType,papersNum,address,aReplenish,tel);

		modelAndView.addObject("list",accountList);
		int count = service.selectPageCount(current,size,name,nature,antiLaunGrade,
				papersType,papersNum,address,aReplenish,tel);
		int totalCount = count%size==0?count/size:count/size+1;
		modelAndView.addObject("totalCount",totalCount);
		modelAndView.addObject("current",current);
		return modelAndView;
	}
}
